package com.chenglai.order.dao;

import com.chenglai.order.pojo.MainOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.Map;

/**
 * @author jiang
 * @created 2023/11/17 14:27:10
 **/
@Repository
public interface MainOrderMapper extends Mapper<MainOrder> {

    @Insert("insert into t_cl_productComment values " +
            "(#{shopId},#{userId},#{orderNum},#{orderStatus},#{orderTime},#{payTime},#{totalSum},#{realSum},#{sendTime},#{successTime},#{orderWuliu},#{orderCom} " +
            ",#{orderWuliuName},#{postSum},#{addressName},#{addressTel},#{addressDetail},#{transactionId},#{returnNote},#{returnReason},#{returnId},#{returnWuliu} " +
            ",#{moNote},#{discountCoupon},#{receiveDetail})")
    @Options(useGeneratedKeys = true, keyProperty = "moId")
    void addMainOrder(MainOrder mainOrder);

    @Select("select order_from from t_cl_mainOrder where order_num = #{orderNum}")
    Integer queryOrderFrom(String orderNum);

    @Select("select shop_id as shopId,user_id as userId from t_cl_mainOrder where order_num = #{orderNum}")
    Map<String,Object> detailByGroupOn(String orderNum);

    @Select("select product_id as goodsId from t_cl_order where order_num = #{orderNum} ")
    Integer queryGoodsId(String orderNum);

    @Select("select shop_id as shopId,transaction_id as transactionId,total_sum as totalSum,real_sum as realSum from t_cl_mainOrder where order_num = #{orderNum}")
    Map<String,Object> queryRefundParam(String orderNum);
}
